import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import './pages/home/home.dart';
import './pages/navigator/navigator.dart';
import './pages/form/form.dart';
import './pages/material/material_components.dart';
import './pages/state/state_management.dart';
import './pages/stream/stream_demo.dart';
import './pages/rxdart/rxdart_demo.dart';
import './pages/bloc/bloc_demo.dart';
import './pages/http/http_demo.dart';
import './pages/animation/animation_demo.dart';
import './pages/i18n/i18n_demo.dart';
import './pages/test/test_demo.dart';
// import './pages/i18n/map/my_demo_localizations.dart';
import './pages/i18n/intl/my_demo_localizations.dart';

// 应用程序入口
void main() => runApp(MyApp());

// 主页面显示
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      //locale: Locale('en', 'US'), // 设置本地语言，若不设置，默认使用本地语言
      locale: Locale('zh', 'CN'), // 设置本地语言，若不设置，默认使用本地语言
      // localeResolutionCallback: (local, supportedLocale) {
      //   return Locale('zh', 'CN'); // 设置本地语言
      // },
      localizationsDelegates: [
        MyDemoLocalizationsDelegate(), // 设置自定义本地化Delegate
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        Locale('en', 'US'),
        Locale('zh', 'CN'),
      ],
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.green,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      // home: NavigatorDemoWidget(),
      initialRoute: '/test', // 设置初始路由
      routes: { // 命名路由
        '/': (context) => NavigatorDemoWidget(),
        '/home': (context) => HomePage(),
        '/about': (context) => AboutPage(title: "About Page"),
        '/form': (context) => FormDemo(),
        '/mdc': (context) => MaterialComponents(),
        '/state': (context) => StateMenagement(),
        '/stateWithModel': (context) => StatelessMenagementDemo(),
        '/stream': (context) => StreamDemo(),
        '/rxdart': (context) => RxDartDemo(),
        '/bloc': (context) => BlocDemo(),
        '/http': (context) => HttpDemo(),
        '/animation': (context) => AnimationDemo(),
        '/i18n': (context) => I18NDemo(),
        '/test': (context) => TestDemo(),
      },
    );
  }
}